﻿using UnityEngine;

public class AABB
{
    private Vector3 _min;
    private Vector3 _max;

    public AABB(Vector3 min, Vector3 max)
    {
        _min = min;
        _max = max;
    }

    public bool IsIntersect(AABB other)
    {
        return ((_min.x >= other._min.x && _min.x <= other._max.x) ||
                (other._min.x >= _min.x && other._min.x <= _max.x)) &&
               ((_min.y >= other._min.y && _min.y <= other._max.y) ||
                (other._min.y >= _min.y && other._min.y <= _max.y)) &&
               ((_min.z >= other._min.z && _min.z <= other._max.z) ||
                (other._min.z >= _min.z && other._min.z <= _max.z));
    }

    public Vector3 GetMin()
    {
        return _min;
    }

    public Vector3 GetMax()
    {
        return _max;
    }
}